package com.ncucoder.soms.service.impl;

import com.ncucoder.soms.dao.OrderMapper;
import com.ncucoder.soms.entity.Order;
import com.ncucoder.soms.service.OrderService;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author <a href="https://www.ncucoder.com">hsowan</a>
 * @date 2019-07-15
 **/
@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    @Override
    public List<Order> listOrders(int perPage, int page) {
        if (page < 1 || perPage < 1) {
            return null;
        }

        // 计算出开始的下标
        int beginIndex = perPage * (page - 1);

        return orderMapper.select(beginIndex, perPage);

    }


}
